import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class MemberPage extends StatefulWidget {
  @override
  _memberPageState createState() => _memberPageState();
}

class _memberPageState extends State<MemberPage> {
  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    return Scaffold(
        appBar: AppBar(
          title: Text('会员中心'),
        ),
        body: Container(
          child: ListView(
            children: <Widget>[
              topHeare(),
            _height20(),
              userItem('我的订单',Icon(Icons.assignment)),
            Row(
              children: <Widget>[
                _gridViewItem(Icon(Icons.bluetooth,size: 30.0,),'待付款'),
                _gridViewItem(Icon(Icons.bluetooth_connected,size: 30.0),'待发货'),
                _gridViewItem(Icon(Icons.bluetooth_disabled,size: 30.0),'待收货'),
                _gridViewItem(Icon(Icons.bluetooth_audio,size: 30.0),'待评价'),
              ],
            ),
            _height20(),
              userItem('领取优惠券',Icon(Icons.bookmark)),
              userItem('我的优惠券',Icon(Icons.book)),
              userItem('地址管理',Icon(Icons.add_location)),
            _height20(),
              userItem('客服电话',Icon(Icons.phone_iphone)),
            ],
          ),
        ));
  }

  Widget topHeare() {
    return Container(
      alignment: Alignment.center,
      width: ScreenUtil().setWidth(750),
      height: ScreenUtil().setHeight(300),
      color: Colors.pinkAccent,
      padding: EdgeInsets.all(10.0),
      child: Column(
        children: <Widget>[
          Container(
            margin: EdgeInsets.only(top: 30.0),
            child: Icon(
              Icons.supervised_user_circle,
              size: 90.0,
              color: Colors.black26,
            ),
          ),
          SizedBox(
            height: ScreenUtil().setHeight(10.0),
          ),
          Text(
            '王二小',
            style: TextStyle(
                fontSize: ScreenUtil().setSp(30.0), color: Colors.white),
          )
        ],
      ),
    );
  }

  //item布局
  Widget userItem(String title, Icon icon) {
    return Container(
      decoration: BoxDecoration(
          color: Colors.white,
        border: Border(bottom: BorderSide(
          color: Colors.black12,width: 0.5
        ))
      ),
      width: ScreenUtil().setWidth(750),
      child: ListTile(
        title: Text(title),
        leading: icon,
        trailing: Icon(Icons.navigate_next),
      ),
    );
  }

  //高度
  Widget _height20(){
    return SizedBox(height: ScreenUtil().setHeight(10.0),);
  }

  //gridViewItem
  Widget _gridViewItem(Icon icon,String title){

    return Container(
      color: Colors.white,
      margin: EdgeInsets.only(top: 1.0),
      height: ScreenUtil().setHeight(150.0),
      width: ScreenUtil().setWidth(187),
      alignment: Alignment.center,
      padding: EdgeInsets.only(top: 20.0),
      child: Column(
        children: <Widget>[
          icon,
         Container(
           padding: EdgeInsets.all(5.0),
           child:Text(
             title,
             style: TextStyle(fontSize: ScreenUtil().setSp(20.0)),
           ),
         )
        ],
      ),
    );
  }


}
